}
this.actor.set_hover(true);
- this._menu.popup();
+ this._menu.open();
this._menuManager.ignoreRelease();
}
};
Signals.addSignalMethods(FolderIcon.prototype);
-var RenameFolderMenu = class RenameFolderMenu extends PopupMenu.PopupMenu {
- constructor(source, folder) {
- super(source.actor, 0.5, St.Side.BOTTOM);
+var RenameFolderMenuItem = GObject.registerClass(
+class RenameFolderMenuItem extends PopupMenu.PopupBaseMenuItem {
+ _init(folder) {
+ super._init({
+ style_class: 'rename-folder-popup-item',
+ reactive: false,
+ });
+ this.setOrnament(PopupMenu.Ornament.HIDDEN);
this._folder = folder;
- // We want to keep the item hovered while the menu is up
- this.blockSourceEvents = true;
-
- let box = new St.BoxLayout({ style_class: 'rename-folder-popup-box' });
- this.box.add_child(box);
-
// Entry
this._entry = new St.Entry({
x_expand: true,
width: 200,
});
- box.add_child(this._entry);
-
- // Focus the text entry on menu pop-up
- this.focusActor = this._entry.clutter_text;
+ this.add_child(this._entry);
this._entry.clutter_text.connect(
'notify::text', this._validate.bind(this));
can_focus: true,
label: _('Rename'),
});
- box.add_child(this._button);
+ this.add_child(this._button);
this._button.connect('clicked', this._updateFolderName.bind(this));
-
- // Chain our visibility and lifecycle to that of the source
- this._sourceMappedId = source.actor.connect('notify::mapped', () => {
- if (!source.actor.mapped)
- this.close();
- });
- source.actor.connect('destroy', () => {
- source.actor.disconnect(this._sourceMappedId);
- this.destroy();
- });
-
- Main.uiGroup.add_actor(this.actor);
}
- popup() {
- let folderName = _getFolderName(this._folder);
-
- this._entry.text = folderName;
- this._entry.clutter_text.set_selection(0, folderName.length);
+ vfunc_map() {
+ this._entry.text = _getFolderName(this._folder);
+ this._entry.clutter_text.set_selection(0, -1);
+ super.vfunc_map();
+ }
- this.open();
+ vfunc_key_focus_in() {
+ super.vfunc_key_focus_in();
+ this._entry.clutter_text.grab_key_focus();
}
_isValidFolderName() {
let newFolderName = this._entry.text.trim();
this._folder.set_string('name', newFolderName);
this._folder.set_boolean('translate', false);
- this.close();
+ this.activate(Clutter.get_current_event());
+ }
+});
+
+var RenameFolderMenu = class RenameFolderMenu extends PopupMenu.PopupMenu {
+ constructor(source, folder) {
+ super(source.actor, 0.5, St.Side.BOTTOM);
+ this.actor.add_style_class_name('rename-folder-popup');
+
+ // We want to keep the item hovered while the menu is up
+ this.blockSourceEvents = true;
+
+ let menuItem = new RenameFolderMenuItem(folder);
+ this.addMenuItem(menuItem);
+
+ // Focus the text entry on menu pop-up
+ this.focusActor = menuItem;
+
+ // Chain our visibility and lifecycle to that of the source
+ this._sourceMappedId = source.actor.connect('notify::mapped', () => {
+ if (!source.actor.mapped)
+ this.close();
+ });
+ source.actor.connect('destroy', () => {
+ source.actor.disconnect(this._sourceMappedId);
+ this.destroy();
+ });
+
+ Main.uiGroup.add_actor(this.actor);
}
};
Signals.addSignalMethods(RenameFolderMenu.prototype);